<template>
  <CommonPanel title="实时出入记录" :loading="loading">
    <div class="main-box">
      <div class="people_card" style="position: relative;" v-for="item, index in list" :key="index">
        <div class="image" :style="{ objectFit: 'cover',height:'50%',backgroundImage:`url(${apiKey + item.picUri})`}" v-on:click="openImageInNewPage(apiKey + item.picUri)">
          <div class="back">
            {{ item.personName }} {{ item.certNo }}
          </div>
          <img  alt="" style="width: 100%;">
        </div>
        <div class="title">{{ item.orgName }}</div>
        <div class="area">{{ item.doorName }}</div>
        <div class="title">{{ item.eventTime }}</div>

        <div
          style="position: absolute;top: 0;left: 0;width: 9%;height: 9%;display: flex;justify-content: center;align-items: center;background: #2e5787;">
          <span> {{ item.inAndOutType === 1 ? "进" : "出" }} </span>
        </div>
      </div>

    </div>
  </CommonPanel>
</template>

<script setup>
import man_1 from '@/assets/man_1.png'
import { computed, onMounted, ref, watch } from "vue";
import { defineEmits, defineProps } from "vue";
const props = defineProps({
  data: Object
});

const list = ref([
])

function openImageInNewPage(imageUrl) {
  window.open(imageUrl,'_black')
       }

let apiKey = "http://192.168.100.1";

onMounted(() => {
  // 在这里访问环境变量
  apiKey = "http://192.168.100.1";
});

watch(() => props.data, (newData) => {
  if (newData) {
    list.value = newData?.entry_records?.slice(0, 4)
  }
});
</script>

<style lang="scss" scoped>
.main-box {
  display: flex;
  box-sizing: border-box;
  padding: 10px 6px;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-column-gap: 30px;

  &>div {
    background: url('../../../assets/image/people.png') no-repeat center 0px;
    background-size: cover;
  }

  .image {
    position: relative;
background-size: contain;
     background-repeat: no-repeat; 
     background-position: center;
    .back {
      position: absolute;
      bottom: 0;
      left: 0;
      background: rgba($color: #000000, $alpha: 0.2);
      color: white;
      font-size: 16px;
      width: 100%;
      padding: 10px 20px;
    }
  }

  .people_card {
    color: white;
    font-size: 14px;
    padding: 12px 12px;

    .title {
      opacity: 0.5;
      margin-top: 10px;
    }

    .area {
      margin-top: 20px;
      font-size: 16px;
    }
  }
}
</style>
